/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment1;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;

/**
 *
 * @author Christopher
 */
public class AssignmentFiles {
    
    public Vector<String> readFileToVector(String filename) throws FileNotFoundException, IOException
    {
        Vector<String>inputLines = new Vector<String>();
        FileInputStream inputStream = new FileInputStream(filename);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        while ((line = bufferedReader.readLine()) != null)
        {
            inputLines.add(line);
        }
        bufferedReader.close();
        inputStream.close();
        return inputLines;
    }
    public void writeStringToFile(String filename, String contents)
    {
        try
        {
            // Create file 
            FileWriter fstream = new FileWriter(filename);
            BufferedWriter out = new BufferedWriter(fstream);
            out.write(contents);
            //Close the output stream
            out.close();
        }catch (Exception e)
        {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }
    }
    
}
